package com.tarena.charging.user.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import com.tarena.charging.user.service.WxLoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class WechatLoginController {
    @Autowired
    private WxLoginService wxLoginService;
    //微信登录
    @GetMapping("/wx/login")
    public JsonResult<Integer> wxLogin(String code,String nickName){
        log.info("拿到微信登录入参 code:{},nickname:{}",code,nickName);
        Integer userId = wxLoginService.login(code, nickName);
        //业务层返回登录之后的userId 传递给前端保存 后续访问携带id 包括webSocket
        return JsonResult.ok(1);
    }
}
